package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.c5.C5Account;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * C5Game账户Mapper接口
 *
 * @author ruoyi
 * @date 2025-10-15
 */
@Repository
@DataSource(value = DataSourceType.CS)
public interface C5AccountMapper extends BaseMapper<C5Account> {
    /**
     * 查询C5Game账户
     *
     * @param id C5Game账户主键
     * @return C5Game账户
     */
    public C5Account selectC5AccountById(Long id);

    /**
     * 查询C5Game账户列表
     *
     * @param c5Account C5Game账户
     * @return C5Game账户集合
     */
    public List<C5Account> selectC5AccountList(C5Account c5Account);

    /**
     * 新增C5Game账户
     *
     * @param c5Account C5Game账户
     * @return 结果
     */
    public int insertC5Account(C5Account c5Account);

    /**
     * 修改C5Game账户
     *
     * @param c5Account C5Game账户
     * @return 结果
     */
    public int updateC5Account(C5Account c5Account);

    /**
     * 删除C5Game账户
     *
     * @param id C5Game账户主键
     * @return 结果
     */
    public int deleteC5AccountById(Long id);

    /**
     * 批量删除C5Game账户
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteC5AccountByIds(String[] ids);

    @Insert("INSERT INTO c5_account (id, user_id, uid, app_key, c5_name, balance, buy_balance, steam_id, avatar) " +
            "VALUES (#{id}, #{userId}, #{uid}, #{appKey}, #{c5Name}, #{balance}, #{buyBalance}, #{steamId}, #{avatar}) " +
            "ON DUPLICATE KEY UPDATE " +
            "uid = VALUES(uid), " +
            "c5_name = VALUES(c5_name), " +
            "balance = VALUES(balance), " +
            "steam_id = VALUES(steam_id), " +
            "avatar = VALUES(avatar)")
    int upsert(C5Account c5Account);
}
